<script type="text/javascript">
/**
 * ------------------------------------------------------
 * 菜单权限管理页面
 * ------------------------------------------------------
 */
$(function(){
	//管理组更改显示权限
	$("#power_edit_group select").change(function(){		
		$.post(BASE+"/admin/manage/power",{"oper":"get_power","group_id":$(this).val()},function(e){
			$("#show_power_edit input[type=radio][value=0]").attr("checked",true);
			$.each(e,function(i,n){
				$("#show_power_edit input[name='power_"+i+"'][value='"+n+"']").attr("checked",true);
			});
		},"json");
	});
	//修改权限
	var submit=$("#power_edit_submit").button();
	submit.click(function(){
		submit.button("disable");
		$.post(BASE+"/admin/manage/power",$("form[name=power]").serialize(),function(e){
			submit.button("enable");
			if(e.status==1){
				artSuccess(e.info);
			}else{
				artError(e.info);
			}
		},"json");
	})
})
</script>

<div id="show_power_edit" class="main">
	<div class="main_left">
	<form name="power" method="post">
		<notempty name="group">
		<div class="title_container">
		<label id="power_edit_group">
			<span class="title_label">{$Think.lang.SELECT_GROUP}</span>
			<span>
				<select name="group_id">
					<foreach name="group" key="group_id" item="g">
					<option value="{$group_id}">{$g["name"]}</option>
					</foreach>
				</select>
			</span>
		</label>
		</div>
		<else/>
		<div class="tip">{$Think.lang.SET_GROUP}</div>
		</notempty>
		<div class="common_table_holder">
			<table cellspacing="0">
				<foreach name="powers" key="i" item="p">
				<tr>
					<td colspan="2">
						<h2>
							<if condition="$p['level'] gt 1">
								<div class="ui-icon ui-icon-carat-1-sw" style="display:inline-block;margin-left:{$p['level']*10}px"></div>
							<else/>
								<span class="ui-icon ui-icon-radio-on" style="display:inline-block;"></span>
							</if>
							{$p["name"]}
						</h2>
					</td>
				</tr>
				<tr>
					<td width="150">
						<if condition="!empty($hasPower) and $hasPower[$i]"> 
							<label><input type="radio" value="1" name="power_{$i}" checked="checked" />{$Think.lang.YES}</label>
							<label><input type="radio" value="0" name="power_{$i}" />{$Think.lang.NO}</label>
						<else /> 
							<label><input type="radio" value="1" name="power_{$i}" />{$Think.lang.YES}</label>
							<label><input type="radio" value="0" name="power_{$i}" checked="checked" />{$Think.lang.NO}</label> 
						</if>
					</td>
					<td>
						<p>{$p['tips']}</p>
					</td>
				</tr>
				</foreach>
			</table>
			<notempty name="group">
			<span><input type="button" value="{$Think.lang.OK}" id="power_edit_submit" /></span>
			<span id="power_edit_status"></span>
			</notempty>
		</div>	
	</form>
	</div>
	<div class="main_right">
		{$Think.lang.TIP_H3}
		{$Think.lang.POWER_TIP}
	</div>
</div>